from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib.sites.models import Site
from tagging.views import tagged_object_list
from models import Story

site = Site.objects.get(id=settings.SITE_ID)

info_dict = {
    'queryset': Story.published_objects.filter(assoc_section__site = settings.SITE_ID),
    'date_field': 'pub_date',
}

urlpatterns = patterns('',
    (r'tag/(?P<tag>[^/]+(?u))/$', tagged_object_list,
     dict(model = Story, paginate_by = 10, allow_empty = True)),

    # Views for all sections
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'django.views.generic.date_based.archive_day', dict(info_dict, template_name = 'stories/section_archive_day.html', extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 
     'django.views.generic.date_based.archive_month', dict(info_dict, template_name = 'stories/section_archive_month.html', extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/$', 
     'django.views.generic.date_based.archive_year', dict(info_dict, make_object_list = True, template_name = 'stories/section_archive_year.html', extra_context={'site': site,})),
    (r'^today/$', 'django.views.generic.date_based.archive_today', dict(info_dict, template_name = 'stories/section_archive_day.html', extra_context={'site': site,})),
    (r'^/?$', 'django.views.generic.date_based.archive_index', dict(info_dict, template_name = 'stories/section_archive.html', extra_context={'site': site,})),

    # Individual section views
    (r'^(?P<section>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$',
     'clapton.apps.stories.views.object_detail'),
    (r'^(?P<section>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'clapton.apps.stories.views.archive_day'),
    (r'^(?P<section>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'clapton.apps.stories.views.archive_month'),
    (r'^(?P<section>[-\w]+)/(?P<year>\d{4})/$', 'clapton.apps.stories.views.archive_year'),
    (r'^(?P<section>[-\w]+)/today/$', 'clapton.apps.stories.views.archive_today'),
    (r'^(?P<section>[-\w]+)/$', 'clapton.apps.stories.views.archive_index'),
)
